import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.ArrayList;
import java.util.List;
/**
 * Clase en la que se desarroya el juego
 * 
 * @author Daniel Varela
 * @version 1.0
 */
public class Mundo extends World
{
    private ArrayList<GreenfootImage> recta;
    private ArrayList<GreenfootImage> curva;
    private ArrayList<GreenfootImage> curva1;
    private Cronometro t;
    private int nubes;
    private int piedras;
    private int tExtra;
    private int vel;
    private int modo;
    private int tecla;
    private int nivel;
    private int estado;
    private boolean ponPiedra;
    private Extremo inicio,fin;
    private Boton boton;
    private Nube nube;
    private Tiempo tiempo;
    private Bpiedra bpiedra;
    private boolean pierde;
    private BotonM jugar,ayuda,creditos;
    
    /**
     * Constructor for objects of class Mundo.
     */
    public Mundo(){ 
        super(20, 14, 30); 
        super.setBackground("Fondo.png");
        modo = 0;
        tecla = 0;
        jugar = new BotonM(1);
        ayuda = new BotonM(2);
        creditos = new BotonM(3);
        nivel = 1;
        estado =0;
        boton = new Boton();
        nube = new Nube();
        tiempo = new Tiempo();
        bpiedra = new Bpiedra();
        vel = 100;
        recta = new ArrayList();
        curva = new ArrayList();
        curva1 = new ArrayList();
        cargaImg();
    }
    
    public void act(){
        this.modoProg();
    }
    
    /**
     * Selecciona la accion de a realizar
     */
    public void modoProg(){
        switch(modo){
                case(0):this.menu();
                    break;
                    
                case(1):this.juega();
                    break;    
                
                case(2):this.ayuda();  
                    break;
                 
                case(3):this.creditos();
                    break;
        }
    }
    
    /**
     * gestiona los niveles del juego
     */
    public void juega(){
            switch(nivel){
                case(1):if(estado == 0){
                            nube = new Nube();
                            tiempo = new Tiempo();
                            bpiedra = new Bpiedra();
                            super.setBackground("Fondo.png");  
                            removeObject(jugar);
                            removeObject(ayuda);
                            removeObject(creditos);
                            this.nivel1();
                            this.selectHabilidad();
                            addObject(t = new Cronometro(30),16,1);
                            addObject(inicio = new Extremo(),0,10);
                            addObject(fin = new Extremo(),19,3);
                            estado = 1;
                            addObject(boton,18,12);
                        }
                        else{
                             this.muestraHabilidades();
                             this.checaLluvia();
                             this.agregaPiedra();
                             this.quitaHabilidades();
                             this.checaPiedra();
                             if(t.sinTiempo())
                                inicio.cambiaBool();
                              if(fin.dameX() == 9 && fin.dameLava()){
                                    Letrero l = new Letrero();
                                    addObject(l,0,0);
                                    l.muestraLetrero("Nivel 2");
                                    Greenfoot.delay(150);
                                    removeObject(l);
                                    nivel = 2;
                                    estado = 0;
                                    super.removeObject(inicio);
                                    super.removeObject(fin);
                                    this.removeAllObjects();
                                    super.removeObject(t);
                             }  
                             else{
                                 if(pierde == true){
                                     Letrero l = new Letrero();
                                     addObject(l,0,0);
                                     l.muestraLetrero("Perdiste");
                                     this.removeAllObjects();
                                     super.removeObject(inicio);
                                     super.removeObject(fin);
                                     super.removeObject(t);
                                     super.removeObject(boton);
                                     Greenfoot.delay(150);
                                     removeObject(l);
                                     pierde =false;
                                     estado = 0;
                                     modo = 0;
                                    }  
                             }       
                        }                        
                    break;
                
                case(2):if(estado == 0){
                            pierde = false;
                            vel = 75;
                            this.selectHabilidad();
                            this.nivel2();
                            addObject(inicio = new Extremo(),0,3);
                            addObject(fin = new Extremo(),19,7);
                            addObject(t = new Cronometro(20),16,1);
                            estado = 1;
                        }
                       else{
                             this.muestraHabilidades();
                             this.checaLluvia();
                             this.agregaPiedra();
                             this.quitaHabilidades();
                             this.checaPiedra();
                             if(t.sinTiempo())
                                inicio.cambiaBool();
                              if(fin.dameX() == 9 && fin.dameLava()){
                                    Letrero l = new Letrero();
                                    addObject(l,0,0);
                                    l.muestraLetrero("Nivel 3");
                                    Greenfoot.delay(150);
                                    removeObject(l);
                                    nivel = 3;
                                    estado = 0;
                                    super.removeObject(inicio);
                                    super.removeObject(fin);
                                    this.removeAllObjects();
                                     super.removeObject(t);
                             }  
                             else{
                                 if(pierde == true){
                                     Letrero l = new Letrero();
                                     addObject(l,0,0);
                                     l.muestraLetrero("Perdiste");
                                     this.removeAllObjects();
                                     super.removeObject(inicio);
                                     super.removeObject(fin);
                                     super.removeObject(t);
                                     super.removeObject(boton);
                                     Greenfoot.delay(150);
                                     removeObject(l);
                                     nivel = 1;
                                     modo = 0;
                                     estado = 0;
                                     pierde = false;
                                    }  
                             }       
                        }
                      break;
                
                case(3):if(estado == 0){
                            pierde = false;
                            vel = 60;
                            this.selectHabilidad();
                            this.nivel3();
                            addObject(inicio = new Extremo(),0,2);
                            addObject(fin = new Extremo(),19,10);
                            addObject(t = new Cronometro(20),16,1);
                            estado = 1;
                        }
                       else{
                             this.muestraHabilidades();
                             this.checaLluvia();
                             this.agregaPiedra();
                             this.quitaHabilidades();
                             this.checaPiedra();
                             if(t.sinTiempo())
                                inicio.cambiaBool();
                              if(fin.dameX() == 9 && fin.dameLava()){
                                    Letrero l = new Letrero();
                                    addObject(l,0,0);
                                    l.muestraLetrero("Ganaste!!");
                                    Greenfoot.delay(150);
                                    removeObject(l);
                                    estado = 0;
                                    modo = 0;
                                    nivel = 1;
                                    pierde = false;
                                    super.removeObject(inicio);
                                    super.removeObject(fin);
                                    super.removeObject(t);
                                    this.removeAllObjects();
                                    super.removeObject(boton);
                             }  
                             else{
                                 if(pierde == true){
                                     Letrero l = new Letrero();
                                     addObject(l,0,0);
                                     l.muestraLetrero("Perdiste");
                                     this.removeAllObjects();
                                     super.removeObject(inicio);
                                     super.removeObject(fin);
                                     super.removeObject(t);
                                     super.removeObject(boton);
                                     Greenfoot.delay(150);
                                     removeObject(l);
                                     vel = 100;
                                     nivel = 1;
                                     modo = 0;
                                     pierde = false;
                                     estado = 0;
                                    }  
                             }       
                        }
                      break;
            
    }
}

    /**
     * Elimina todos los objetos del mapa;
     */
    public void removeAllObjects(){
        super.removeObjects(super.getObjects(Curva.class));    
        super.removeObjects(super.getObjects(Recta.class));    
        super.removeObjects(super.getObjects(Bpiedra.class));  
        super.removeObjects(super.getObjects(Nube.class));  
        super.removeObjects(super.getObjects(Lluvia.class));  
        super.removeObjects(super.getObjects(Tiempo.class));
    }
    
   
    
    /**
     * Cambia la variable modo
     * @param n el modo del mundo
     */ 
    public void tomaModo(int n){
        modo = n;
    }
    
    /**
     * cambia el fondo por el que muestra los creditos
     */
    public void creditos(){
        if(tecla == 0 ){
                this.setBackground("Creditosf.png");
                removeObject(jugar);
                removeObject(ayuda);
                removeObject(creditos);
                tecla = 1;
        }
        else{
            if(Greenfoot.isKeyDown("enter") && tecla == 1){
                     modo = 0;
                     tecla = 0;
               }
        }
    }
    
    /**
     * Gestiona el menu del juego
     */
    public void menu(){
            this.setBackground("inicio.png");
            addObject(jugar,4,10);
            addObject(ayuda,10,11);
            addObject(creditos,16,10);
    }
    
    /**
     * Muestra el menu da ayuda
     */
    public void ayuda(){
            
            if(tecla == 0 ){
                this.setBackground("Ayuda1.png");
                removeObject(jugar);
                removeObject(ayuda);
                removeObject(creditos);
                tecla = 1;
            }
            else{
                if(Greenfoot.isKeyDown("enter")){
                    this.setBackground("Ayuda2.png");  
                    Greenfoot.delay(500);
                    modo = 0;
                    tecla = 0;
                }
            }
    }
    
    /**
     * Cambia el valor de pierde 
     */
    public void cPierde(){
        if(pierde == true){
            pierde = false;
        }
        else {
            pierde = true;
        }
    }   
    
    /**
     * Quita las habilidades de l mapa
     */
    public void quitaHabilidades(){
        if(tiempo.dameNum() == 0){
            removeObject(tiempo);
        }
        
        if(nube.dameNum() == 0){
            removeObject(nube);
        }
        
        if(bpiedra.dameNum() == 0){
            removeObject(bpiedra);
        }
    }
    
    /**
     * Muestra las habilidades especiales en el juego
     */
    public void muestraHabilidades(){
        if(tiempo.dameNum() != 0){
            addObject(tiempo,1,12);
        }  
        
        if(nube.dameNum() != 0){
            addObject(nube,3,12);
        }
        
        if(bpiedra.dameNum() != 0){
            addObject(bpiedra,5,12);
        }
    }
    
    /**
     * incrementa la cantidad de habilidades especiales 
     * de acuerdo con un numero aleatorio
    */
    public void selectHabilidad(){
        switch(Greenfoot.getRandomNumber(3)){
            case(0):tiempo.incrementaNum();
                break;
             
            case(1):nube.incrementaNum();
                break;
                
            case(2):bpiedra.incrementaNum();
                break;
            
        }
        
    }
    
    /**
     * Agrega una piedra a el mapa
     */
    public void nvaPiedra(){
        ponPiedra = true;
    }
    
    /**
     *Crea un objeto de la clase lluvia y lo agrega el mundo
     */
    public void hasLlover(){
        Lluvia l = new Lluvia();
        addObject(l,1,15);
        l.llueve();
    }
    
    /**
     * cambia el fondo del juego
     */
    public void cambiaFondo(String x){
        super.setBackground(x);    
    }
    
    /**
     * checa que las piedra aun tengan tiempo 
     */
    public void checaPiedra(){
        List<Piedra> p;
        p = super.getObjects(Piedra.class); 
        
        if(p != null){
           for(Piedra it: p){
               if(!it.existe()){
                   super.removeObjects(p);
               }
           }
       }
    }
    
    /**
     * Checa que la lluvia no haya acabado
     */
    public void checaLluvia(){
        List<Lluvia> ll;
        ll = super.getObjects(Lluvia.class); 
        
        if(ll != null){
           for(Lluvia it: ll){
               if(!it.existe()){
                   super.removeObjects(ll);
               }
           }
       }
    }
    
    
    /**
     * Agrega la piedra al mapa
     */
    public void agregaPiedra(){
        if(ponPiedra == true && (Greenfoot.getMouseInfo()).getButton() == 1){
                Piedra p = new Piedra();
                addObject(p,(Greenfoot.getMouseInfo()).getX(),(Greenfoot.getMouseInfo()).getY());
                ponPiedra = false;
       }
    }
    
    /**
     * cambia el timepo de juego
     * 
     * @param x es una cantidad de tiempo que se se remplaza por el tiempo actual
     */
    public void cambiaTiempo(long x){
        t.tomaTiempo(x);    
    }
    
    /**
     * aumenta el cronometro
     * @param x en una cantidad de tiempo que se le suma al cronometro
     */
    public void aumentaTiempo(long x){
        t.sumaTiempo(x);    
    }
    
    /**
     * regresa la variable vel
     * @return vel es la velocidad a la cual se mueve la lava
     */
    public int dameVel(){
        return vel;
    }   
    
    /**
     * asigna un valor a la variable vel
     * 
     * @param v es la velocidad de la lava en milisegundos
     */
    public void tomaVel(int v){
        vel = v;
    }
    
    /**
     * Carga las imagenes del camino con lava
     */
    public void cargaImg(){
        
        recta.add(new GreenfootImage("recta1.png"));   
        recta.add(new GreenfootImage("recta2.png"));
        recta.add(new GreenfootImage("recta3.png"));
        recta.add(new GreenfootImage("recta4.png"));
        recta.add(new GreenfootImage("recta5.png"));
        recta.add(new GreenfootImage("recta6.png"));
        recta.add(new GreenfootImage("recta7.png"));
        recta.add(new GreenfootImage("recta8.png"));
        recta.add(new GreenfootImage("recta9.png"));
        
        curva.add(new GreenfootImage("curva1.png"));
        curva.add(new GreenfootImage("curva2.png"));
        curva.add(new GreenfootImage("curva3.png"));
        curva.add(new GreenfootImage("curva4.png"));
        curva.add(new GreenfootImage("curva5.png"));
        curva.add(new GreenfootImage("curva6.png"));
        curva.add(new GreenfootImage("curva7.png"));
        curva.add(new GreenfootImage("curva8.png"));
        
        curva1.add(new GreenfootImage("curva10.png"));
        curva1.add(new GreenfootImage("curva20.png"));
        curva1.add(new GreenfootImage("curva30.png"));
        curva1.add(new GreenfootImage("curva40.png"));
        curva1.add(new GreenfootImage("curva50.png"));
        curva1.add(new GreenfootImage("curva60.png"));
        curva1.add(new GreenfootImage("curva70.png"));
        curva1.add(new GreenfootImage("curva80.png"));
        
    }
    
    /**
     * Regresa un objeto de la lista de rectas
     * @param x es la posicion de la imagen a cargar
     */
    public GreenfootImage dameRecta(int x){        
        return (recta.get(x));    
    }
    
    /**
     * Regresa un objeto de la lista de curvas
     * @param x es la posicion de la imagen a cargar
     */
    public GreenfootImage dameCurva(int x){       
        return (curva.get(x));    
    }
    
    /**
     * Regresa un objeto de la lista de curvas1
     * @param x es la posicion de la imagen a cargar
     */
    public GreenfootImage dameCurva1(int x){
        return    (curva1.get(x));
    }
    
    /**
     * Genera un numero aleatorio para la posicion de la curva
     */
    public int RandomNum(){
            int x = Greenfoot.getRandomNumber(6);
            
            if(x < 2)
                return (x+2);
                
            else 
                return x;
    }
    
    /**
     * prepara el nivel 1
    */
    public void nivel1(){
        Curva cur1 = new Curva(RandomNum());
        addObject(cur1,1,10);
        Curva cur2 = new Curva(RandomNum());
        addObject(cur2,1,9);
        Curva cur3 = new Curva(RandomNum());
        addObject(cur3,2,8);
        Curva cur4 = new Curva(RandomNum());
        addObject(cur4,2,9);
        Curva cur5 = new Curva(RandomNum());
        addObject(cur5,2,10);
        Curva cur6 = new Curva(RandomNum());
        addObject(cur6,3,8);
        Recta rec1 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec1,3,6);
        Recta rec2 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec2,3,7);
        Recta rec3 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec3,3,10);
        Curva cur7 = new Curva(RandomNum());
        addObject(cur7,4,8);
        Curva cur8 = new Curva(RandomNum());
        addObject(cur8,4,10);
        Recta rec4 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec4,4,7);
        Recta rec5 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec5,4,9);
        Recta rec6 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec6,5,8);
        Recta rec7 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec7,5,10);
        Curva cur9 = new Curva(RandomNum());
        addObject(cur9,6,6);
        Curva cur10 = new Curva(RandomNum());
        addObject(cur10,6,8);
        Curva cur11 = new Curva(RandomNum());
        addObject(cur11,6,10);
        Recta rec8 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec8,6,7);
        Recta rec9 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec9,6,9);
        Recta rec10 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec10,7,6);
        Recta rec11 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec11,7,10);
        Recta rec12 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec12,8,7);
        Recta rec13 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec13,8,10);
        Curva cur12 = new Curva(RandomNum());
        addObject(cur12,8,6);
        Curva cur13 = new Curva(RandomNum());
        addObject(cur13,8,8);
        Recta rec14 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec14,9,5);
        Recta rec15 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec15,9,9);
        Curva cur14 = new Curva(RandomNum());
        addObject(cur14,9,4);
        Curva cur15 = new Curva(RandomNum());
        addObject(cur15,9,6);
        Curva cur16 = new Curva(RandomNum());
        addObject(cur16,9,8);
        Curva cur17 = new Curva(RandomNum());
        addObject(cur17,9,10);
        Recta rec16 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec16,10,4);
        Recta rec17 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec17,10,7);
        Recta rec18 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec18,10,8);
        Curva cur19 = new Curva(RandomNum());
        addObject(cur19,10,6);
        Recta rec19 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec19,11,4);
        Curva cur20 = new Curva(RandomNum());
        addObject(cur20,12,4);
        Curva cur21 = new Curva(RandomNum());
        addObject(cur21,12,7);
        Curva cur22 = new Curva(RandomNum());
        addObject(cur22,12,9);
        Recta rec20 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec20,12,5);
        Recta rec21 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec21,12,6);
        Recta rec22 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec22,12,8);
        Curva cur23 = new Curva(RandomNum());
        addObject(cur23,13,8);
        Curva cur24 = new Curva(RandomNum());
        addObject(cur24,13,9);
        Recta rec23 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec23,13,7);
        Curva cur25 = new Curva(RandomNum());
        addObject(cur25,14,5);
        Curva cur26 = new Curva(RandomNum());
        addObject(cur26,14,7);
        Recta rec24 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec24,14,6);
        Recta rec25 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec25,14,8);
        Recta rec26 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec26,15,5);
        Curva cur27 = new Curva(RandomNum());
        addObject(cur27,16,3);
        Curva cur28 = new Curva(RandomNum());
        addObject(cur28,16,5);
        Curva cur29 = new Curva(RandomNum());
        addObject(cur29,16,7);
        Recta rec27 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec27,16,4);
        Recta rec28 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec28,16,6);
        Curva cur30 = new Curva(RandomNum());
        addObject(cur30,17,2);
        Curva cur31 = new Curva(RandomNum());
        addObject(cur31,17,3);
        Curva cur32 = new Curva(RandomNum());
        addObject(cur32,17,5);
        Curva cur33 = new Curva(RandomNum());
        addObject(cur33,17,7);
        Recta rec29 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec29,17,6);
        Curva cur34 = new Curva(RandomNum());
        addObject(cur34,18,2);
        Curva cur35 = new Curva(RandomNum());
        addObject(cur35,18,3);
        Curva cur36 = new Curva(RandomNum());
        addObject(cur36,18,4);
        Curva cur37 = new Curva(RandomNum());
        addObject(cur37,18,5);
        
        
        
    }
    
    /**
     * prepara el nivel 2
     */
    public void nivel2(){
        Recta rec1 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec1,1,3);
        Curva cur1 = new Curva(RandomNum());
        addObject(cur1,2,1);
        Curva cur2 = new Curva(RandomNum());
        addObject(cur2,2,3);
        Curva cur3 = new Curva(RandomNum());
        addObject(cur3,2,4);
        Recta rec2 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec2,2,2);
        Recta rec3 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec3,3,1);
        Recta rec4 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec4,3,4);
        Recta rec5 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec5,3,7);
        Curva cur4 = new Curva(RandomNum());
        addObject(cur4,3,6);
        Curva cur5 = new Curva(RandomNum());
        addObject(cur5,4,1);
        Curva cur6 = new Curva(RandomNum());
        addObject(cur6,4,3);
        Recta rec6 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec6,4,2);
        Recta rec7 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec7,4,4);
        Recta rec8 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec8,4,6);
        Curva cur7 = new Curva(RandomNum());
        addObject(cur7,5,3);
        Curva cur8 = new Curva(RandomNum());
        addObject(cur8,5,4);
        Curva cur9 = new Curva(RandomNum());
        addObject(cur9,5,6);
        Recta rec9 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec9,5,5);
        Recta rec10 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec10,6,3);
        Recta rec11 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec11,6,6);
        Curva cur10 = new Curva(RandomNum());
        addObject(cur10,7,3);
        Curva cur11 = new Curva(RandomNum());
        addObject(cur11,7,6);
        
        Recta rec12 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec12,7,4);
        Recta rec13 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec13,7,5);
        Recta rec14 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec14,7,7);
        Recta rec15 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec15,7,8);
        Recta rec16 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec16,8,6);
        Recta rec17 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec17,8,8);
        
        Curva cur12 = new Curva(RandomNum());
        addObject(cur12,9,5);
        Curva cur13 = new Curva(RandomNum());
        addObject(cur13,9,6);
        Curva cur14 = new Curva(RandomNum());
        addObject(cur14,9,8);
        Recta rec18 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec18,9,7);
        Recta rec19 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec19,10,5);
        Recta rec20 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec20,10,9);
        
        Curva cur15 = new Curva(RandomNum());
        addObject(cur15,11,3);
        Curva cur16 = new Curva(RandomNum());
        addObject(cur16,11,5);
        Curva cur17 = new Curva(RandomNum());
        addObject(cur17,11,7);
        Curva cur18 = new Curva(RandomNum());
        addObject(cur18,11,8);
        Curva cur19 = new Curva(RandomNum());
        addObject(cur19,11,10);
        Recta rec21 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec21,11,4);
        Recta rec22 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec22,11,6);
        Recta rec23 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec23,11,9);
        
        Curva cur20 = new Curva(RandomNum());
        addObject(cur20,12,8);
        Curva cur21 = new Curva(RandomNum());
        addObject(cur21,12,10);
        Recta rec24 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec24,12,3);
        Recta rec25 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec25,12,7);
        Recta rec26 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec26,12,9);
        
        Curva cur22 = new Curva(RandomNum());
        addObject(cur22,13,4);
        Curva cur23 = new Curva(RandomNum());
        addObject(cur23,13,7);
        Curva cur24 = new Curva(RandomNum());
        addObject(cur24,13,9);
        Recta rec27 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec27,13,5);
        Recta rec28 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec28,13,6);
        Recta rec29 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec29,13,8);
        
        Curva cur25 = new Curva(RandomNum());
        addObject(cur25,14,7);
        Curva cur26 = new Curva(RandomNum());
        addObject(cur26,14,8);
        Recta rec30 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec30,14,3);
        Recta rec31 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec31,14,9);
        
        Curva cur27 = new Curva(RandomNum());
        addObject(cur27,15,4);
        Curva cur28 = new Curva(RandomNum());
        addObject(cur28,15,5);
        Curva cur29 = new Curva(RandomNum());
        addObject(cur29,15,7);
        Curva cur30 = new Curva(RandomNum());
        addObject(cur30,15,9);        
        Recta rec32 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec32,15,6);
        Recta rec33 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec33,15,8);
        
        Recta rec34 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec34,16,5);
        Recta rec35 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec35,16,7);
        
        Curva cur31 = new Curva(RandomNum());
        addObject(cur31,17,5);
        Curva cur32 = new Curva(RandomNum());
        addObject(cur32,17,6);    
        Curva cur33 = new Curva(RandomNum());
        addObject(cur33,17,7);
        Curva cur34 = new Curva(RandomNum());
        addObject(cur34,17,9);
        Recta rec36 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec36,17,8);
        
        Recta rec37 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec37,18,8);
        Curva cur35 = new Curva(RandomNum());
        addObject(cur35,18,6);    
        Curva cur36 = new Curva(RandomNum());
        addObject(cur36,18,7);
        Curva cur37 = new Curva(RandomNum());
        addObject(cur37,18,9);
    }
    
    /**
     * prepara el nivel 3
     */
    public void nivel3(){
       
        Curva cur1 = new Curva(RandomNum());
        addObject(cur1,1,2);
        Curva cur2 = new Curva(RandomNum());
        addObject(cur2,1,3);
        Recta rec1 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec1,2,3);
        Curva cur3 = new Curva(RandomNum());
        addObject(cur3,3,3);
        Recta rec2 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec2,3,4);
        Recta rec4 = new Recta(Greenfoot.getRandomNumber(1));
        addObject(rec4,3,4);
        Curva cur5 = new Curva(RandomNum());
        addObject(cur5,3,5);
        Recta rec3 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec3,2,5);
        Curva cur6 = new Curva(RandomNum());
        addObject(cur6,1,5);
         Curva cur7 = new Curva(RandomNum());
        addObject(cur7,1,6);
         Curva cur8 = new Curva(RandomNum());
        addObject(cur8,0,6);
         Curva cur9 = new Curva(RandomNum());
        addObject(cur9,2,6);
         Curva cur10 = new Curva(RandomNum());
        addObject(cur10,3,6);
        Curva cur11 = new Curva(RandomNum());
        addObject(cur11,2,7);
        Recta rec5 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec5,0,7);
        Curva cur12 = new Curva(RandomNum());
        addObject(cur12,0,8);
        Recta rec6 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec6,1,8);
        Recta rec7 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec7,2,8);
        Curva cur13 = new Curva(RandomNum());
        addObject(cur13,3,8);
        Recta rec8 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec8,3,7);
        Recta rec9 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec9,3,9);      
        Curva cur14 = new Curva(RandomNum());
        addObject(cur14,3,10);
        Recta rec10 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec10,4,6);
        Recta rec11 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec11,4,7);
        Recta rec12 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec12,4,10);
        Curva cur15 = new Curva(RandomNum());
        addObject(cur15,5,4);
        Curva cur16 = new Curva(RandomNum());
        addObject(cur16,5,6);
        Curva cur17 = new Curva(RandomNum());
        addObject(cur17,5,8);
        Curva cur18 = new Curva(RandomNum());
        addObject(cur18,5,10);
        Curva cur19 = new Curva(RandomNum());
        addObject(cur19,5,11);
        Recta rec13 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec13,5,5);
        Recta rec14 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec14,5,7);
        Recta rec15 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec15,5,9);
        Curva cur20 = new Curva(RandomNum());
        addObject(cur20,6,6);
        Curva cur21 = new Curva(RandomNum());
        addObject(cur21,6,7);
        Curva cur22 = new Curva(RandomNum());
        addObject(cur22,6,8);
        Recta rec16 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec16,6,4);
        Curva cur23 = new Curva(RandomNum());
        addObject(cur23,7,3);
        Curva cur24 = new Curva(RandomNum());
        addObject(cur24,7,5);
        Recta rec17 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec17,7,4);
        Recta rec18 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec18,7,6);
        Recta rec19 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec19,7,8);
        Curva cur25 = new Curva(RandomNum());
        addObject(cur25,8,5);
        Curva cur26 = new Curva(RandomNum());
        addObject(cur26,8,8);
        Curva cur27 = new Curva(RandomNum());
        addObject(cur27,8,10);
        Recta rec20 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec20,8,2);
        Recta rec21 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec21,8,6);
        Recta rec22 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec22,8,7);
        Recta rec23 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec23,9,6);
        Curva cur28 = new Curva(RandomNum());
        addObject(cur28,10,4);
        Curva cur29 = new Curva(RandomNum());
        addObject(cur29,10,6);
        Curva cur30 = new Curva(RandomNum());
        addObject(cur30,10,8);
        Recta rec24 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec24,10,5);
        Recta rec25 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec25,10,7);
        Recta rec26 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec26,11,4);
        Recta rec27 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec27,11,8);        
        Curva cur31 = new Curva(RandomNum());
        addObject(cur31,12,2);
        Curva cur32 = new Curva(RandomNum());
        addObject(cur32,12,4);
        Curva cur33 = new Curva(RandomNum());
        addObject(cur33,12,7);
        Curva cur34 = new Curva(RandomNum());
        addObject(cur34,12,9);       
        Recta rec28 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec28,12,3);
        Recta rec29 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec29,12,5);
        Recta rec30 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec30,12,6);
        Recta rec31 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec31,12,8);
        Recta rec32 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec32,13,2);
        Recta rec33 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec33,13,7);
        Curva cur35 = new Curva(RandomNum());
        addObject(cur35,14,2);   
        Curva cur36 = new Curva(RandomNum());
        addObject(cur36,14,3);   
        Curva cur37 = new Curva(RandomNum());
        addObject(cur37,14,6);   
        Curva cur38 = new Curva(RandomNum());
        addObject(cur38,14,7);   
        Curva cur39 = new Curva(RandomNum());
        addObject(cur39,14,9);  
        Recta rec34 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec34,14,8);
        Curva cur40 = new Curva(RandomNum());
        addObject(cur40,15,4);   
        Curva cur41 = new Curva(RandomNum());
        addObject(cur41,15,6);
        Recta rec35 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec35,15,3);
        Recta rec36 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec36,15,5);
        Recta rec37 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec37,15,9);
        Curva cur42 = new Curva(RandomNum());
        addObject(cur42,16,8);
        Curva cur43 = new Curva(RandomNum());
        addObject(cur43,16,9);
        Curva cur44 = new Curva(RandomNum());
        addObject(cur44,16,10);
        Recta rec38 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec38,16,4);
        Curva cur45 = new Curva(RandomNum());
        addObject(cur45,17,4);
        Curva cur46 = new Curva(RandomNum());
        addObject(cur46,17,5);
        Curva cur47 = new Curva(RandomNum());
        addObject(cur47,17,6);
        Recta rec39 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec39,17,8);
        Recta rec40 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec40,17,10);
        Curva cur48 = new Curva(RandomNum());
        addObject(cur48,18,8);
        Recta rec41 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec41,18,5);
        Recta rec42 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec42,18,6);
        Recta rec43 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec43,18,9);        
        Recta rec44 = new Recta(Greenfoot.getRandomNumber(2));
        addObject(rec44,18,10);        
        Curva cur49 = new Curva(RandomNum());
        addObject(cur49,19,5);
        Curva cur50 = new Curva(RandomNum());
        addObject(cur50,19,6);
    }
}
